#ifndef JUVLMENGINE_H
#define JUVLMENGINE_H

#include <functional>
#include <QTEGui/qteguiglobal.h>
#include <QObject>

namespace QTE
{

class JUVLMEnginePrivate;

// A simple physics engine.

// J Uniformly variable linear motion engine

class QTEGUI_EXPORT JUVLMEngine : public QObject
{
	Q_OBJECT

public:
	explicit JUVLMEngine(QObject *parent = nullptr);
	~JUVLMEngine();

public:
	struct Bind
	{
		QWidget *widget = nullptr;
		std::function<void(const QPoint&)> actionTriggered = nullptr;
		std::function<void(const QPoint&)> inertanceStarted = nullptr;
		std::function<bool(const QPoint&)> running = nullptr;
		std::function<void()> stop = nullptr;
	};

public:
	void bind(const Bind &action);
	void unbound(const QWidget *widget);

public Q_SLOTS:
	void stopMotionImmediately(const QWidget *widget);
	void stopMotion(const QWidget *widget);
	void setRefreshRate(int rate); //default:50Hz (20~75)

public:
	bool isBind(const QWidget *widget) const;
	bool isURLMing(const QWidget *widget) const;
	int refreshRate() const;

public:
	static JUVLMEngine &globalInstance();

private:
	JUVLMEnginePrivate *d_ptr;
	Q_DISABLE_COPY(JUVLMEngine)
};

} //namespace QTE


#endif //JUVLMENGINE_H
